//
// This class reads questions and answers from a database file.
//

#pragma once

#include "unicode.h"
#include <vector>
#include <fstream>

using namespace std;

// Store the information of a question
typedef struct QuesInfor {
	wchar_t *question;
	vector<wchar_t*> choice;
	int answer;
} QUESINFOR, *PQUESINFOR;

class QUESTION
{
	int nQuestion;
	vector<PQUESINFOR> data;			// Question bank
	fstream fData;						// Data file
public:
	QUESTION(void);
	~QUESTION(void);					// Free data
	bool AddQuestion(PQUESINFOR);		// Add a question to question bank
	bool OpenDataFile(char *fName);		// Open fName data file
	int NoQuestion();					// The number of questions
	PQUESINFOR ReadQuestion();			// Read one by one a question from the data file
	bool LoadData();					// Load all questions from file
	PQUESINFOR& operator[]  (int i);
};